import request from '@/utils/request'

// 区域树接口
export function fetchTree() {
  return request({
    url: '/api/admin/region/tree',
    method: 'get'
  });
}

// 新增区域接口
export function addRegionObj(obj) {
  return request({
    url: '/api/admin/region',
    method: 'post',
    data: obj
  })
}


// 批量新增采集员接口
export function addGather(obj) {
  return request({
    url: '/api/admin/regionCollecter/addGather',
    method: 'post',
    data: obj
  })
}

// 修改区域接口
export function putRegionObj(id, obj) {
  return request({
    url: '/api/admin/region/' + id,
    method: 'put',
    data: obj
  })
}

// 查询单个区域对象
export function getRegionObj(id) {
  return request({
    url: '/api/admin/region/' + id,
    method: 'get'
  })
}

// 查询社区采集员
export function getGather(id) {
  return request({
    url: '/api/admin/regionCollecter/getGather/' + id,
    method: 'get'
  })
}

// 删除区域对象 todo
export function delRegionObj(id) {
  return request({
    url: '/api/admin/region/' + id,
    method: 'DELETE',
    params: { id }
  })
}

// 区域唯一性验证
export function validationRegion(parentId, name, type) {
  return request({
    url: '/api/admin/region/validationRegion/' + parentId,
    method: 'get',
    params: { name, type }
  })
}

export function findLike(username, id) {
  return request({
    url: '/api/admin/regionCollecter/findLike',
    method: 'get',
    params: { username, id }
  })
}

export function findUser(groupId) {
  return request({
    url: '/api/admin/regionCollecter/findUser',
    method: 'get',
    params: { groupId }
  })
}

// 查找街道
export function findStreets() {
  return request({
    url: '/api/admin/region/streets',
    method: 'get'
  })
}

// 查找社区
export function findCommunitys(streetId) {
  return request({
    url: '/api/admin/region/communitys',
    method: 'get',
    params: { streetId }
  })
}
